{extend name="index-layout-user" /} {block name="pagecss"}
<link rel="stylesheet" href="__STATIC__/index/css/style_tr.css" />
<link rel="stylesheet" href="__STATIC__/index/css/register.css" />
{/block} {block name="content"}
<div class="banner" style="height:60px;">
  <div class="wrapper">
    <h2 class="wow fadeInUp" style="padding-top:5px;">支付</h2>
  </div>
</div>
<div class="login1" style="min-height: 600px;">
  <div id="paymentBox">
    <div class="login-bd">
      <div style="width: 100%; text-align: center;">
        <div class="login-btn"><input type="button" class="btn" value="点击支付￥955 元" onclick="submitOrder(955)" />
          <div class="login-btn"><input type="button" class="btn" value="点击支付￥1910 元" onclick="submitOrder(1910)" />
            <div class="login-btn"><input type="button" class="btn" value="点击支付￥2865 元" onclick="submitOrder(2865)" />
              <div class="login-btn"><input type="button" class="btn" value="点击支付￥3820 元" onclick="submitOrder(3820)" />
                <div class="login-btn"><input type="button" class="btn" value="点击支付￥4775 元"
                    onclick="submitOrder(4775)" />

                </div>
              </div>
            </div>
          </div>

          <div class="login-wp" style="display:none;" id="divResult">
            <div style="width: 100%;margin: 0 auto;font-size: 25px;">
              <h1>请使用微信扫码支付</h1>
              <div id="divQRImg"></div>
              <h1><a href="/payment/shop1">返回</a></h1>
            </div>
          </div>
        </div>
        {/block} {block name="pagejs"}
        <script type="text/javascript">
          var blockIndex = 0
          $.ajaxSetup({
            beforeSend: function () {
              blockIndex = layer.load(1, {
                shade: 0.6
              })
            },
            error: function (xhr, status, error) {
              layer.msg(error, {
                icon: 2,
                closeBtn: 0,
                shade: 0.6
              })
            },
            complete: function () {
              layer.close(blockIndex)
            }
          })

          layui.use('layer', function () {
            $('#btnSubmit').click(function () {
              submitOrder()
            })
          })


          function submitOrder(amount) {
            var $ = layui.$
            var uId = 100012

            if (amount == undefined) {
              var amount = parseFloat(txtAmount.val()).toFixed(2)
            }

            var $ = layui.$
            var layer = layui.layer
            var divResult = $('#divResult')
            if (uId && amount) {
              $.ajax({
                url: "{:url('index/Test/api',['code' => 'F8001'])}",
                type: 'POST',
                data: {
                  uid: uId,
                  amount: amount
                },
                success: function (res) {
                  $('#paymentBox').display = "none"
                  if (res.code == 1) {
                    // layer.msg(res.msg, {
                    //   closeBtn: 0,
                    //   shade: 0.6
                    // })
                    if (res.data.type === 'A002' || res.data.type === 'A005' || res.data.type === 'G0071' || res
                      .data
                      .type === 'F8001') {
                      // window.open(res.data.pay_url)
                      location.href = res.data.pay_url;
                    } else {
                      if (
                        res.data.pay_url &&
                        (res.data.pay_url.indexOf('https://') >= 0 ||
                          res.data.pay_url.indexOf('http://') >= 0)
                      ) {
                        $('#divQRImg').html(
                          '<img src="' +
                          res.data.pay_url +
                          '" />'
                        )

                        $('#paymentBox').css('display', 'none')
                        divResult.css('display', 'block')


                      } else {
                        layer.msg(res.data.msg, {
                          icon: 2,
                          closeBtn: 0,
                          shade: 0.6
                        })
                      }
                    }
                  } else {
                    layer.msg(res.msg, {
                      icon: 2,
                      closeBtn: 0,
                      shade: 0.6
                    })
                  }
                }
              })
            } else {
              layer.msg('')
            }
          }
        </script>
        {/block}